using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WbsEditor
{
    public partial class WorkloadInfoForm : Form
    {
        public WorkloadInfoForm()
        {
            InitializeComponent();
        }

        private WbsNode _node;
        public WbsNode WbsNode
        {
            get { return _node; }
            set { _node = value; }
        }

        public void DisplayForm()
        {
            if (null == WbsNode)
            {
                Dispose();
                return;
            }

            PersonWorkload[] workloads = WbsExporter.ExtractWorkload(WbsNode);

            foreach (PersonWorkload pw in workloads)
            {
                int newRowId = _workloadGrid.Rows.Add();
                DataGridViewRow row = _workloadGrid.Rows[newRowId];
                row.Cells["AssignedTo"].Value = pw.Name;
                row.Cells["NoOfTasks"].Value = pw.TasksAssigned;
                row.Cells["RemainingWork"].Value = pw.RemainingWork;
                row.Cells["CompletedWork"].Value = pw.CompletedWork;
            }

            ShowDialog();
        }

        private void _closeButton_Click(object sender, EventArgs e)
        {
            Dispose();
        }

        private void _copyClipButton_Click(object sender, EventArgs e)
        {
            WbsExporter.CopyWorkloadToClipboard(WbsNode);
        }
    }
}